import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import {createStore} from './redux';


const store=createStore(reducer);
function reducer (state={num:2},action){
    state=JSON.parse(JSON.stringify(state));
    switch(action.type){
        case 'add':
            state.num++;
            break;
        default :
        return state;
    }
    return state;
}

function render(){
    ReactDOM.render(
        <App store={store}/>,
        document.getElementById('root')
    )
}
render();

store.subscribe(()=>{
    render();
})